package cn.com.w.bootdemo.controller;

import cn.com.w.commons.base.vo.ResponseBaseVO;
import cn.com.w.bootdemo.vo.UserVo;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/user")
public class UserController {


    @PostMapping("/list")
    public ResponseBaseVO getUserList(@Valid UserVo userVo, BindingResult bindingResult){
        ResponseBaseVO result = ResponseBaseVO.ok();
        

        if (bindingResult.hasErrors()) {
            result.setCode(ResponseBaseVO.ERROR_CODE);
            result.setMessage(bindingResult.getFieldError().getDefaultMessage());
        }

        return result;
    }

}
